﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;

namespace Prototype1
{
    public partial class FormExpenseReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String name = this.tb_Name.Text;
            String comments = this.tb_Comments.Text;

            ExpenseReport expenseReport = new ExpenseReport();
            expenseReport.Name = name;
            expenseReport.Comments = comments;
            //user é o que estiver autenticado, ver nos cookies provávelmente
            /*Mas atenção que há coisas já feitas, forms authentication etc*/

            //temporariamente o user é introduzido numa textbox.
            expenseReport.UserEmail = this.tb_UserEmail.Text;
            expenseReport.Id = Guid.NewGuid();
            expenseReport.CreationDate = DateTime.Now;

            //submit para a DB
            using (DataAccessDataContext dc = new DataAccessDataContext())
            {
                dc.ExpenseReports.InsertOnSubmit(expenseReport);
                dc.SubmitChanges();
            }
        }
    }
}
